package com.hudson.plugin.server.hibernateDB.domain.dao;

import com.hudson.plugin.server.hibernateDB.internal.domain.entity.BuildsEntity;
import com.hudson.plugin.server.hibernateDB.internal.domain.entity.ProjectsEntity;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/29/11
 * Time: 10:38 PM
 * To change this template use File | Settings | File Templates.
 */
public interface BuildsDAOInterface {
    // property constants
    String BUILD_NUM = "buildNum";
    String CAUSE_ACTION = "causeAction";
    String AUTHOR = "author";
    String RESULT = "result";
    String DURATION = "duration";
    String BUILD_ON = "buildOn";
    String FAIL_COUNT = "failCount";
    String SKIP_COUNT = "skipCount";
    String TOTAL_COUNT = "totalCount";

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void save(BuildsEntity transientInstance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void delete(BuildsEntity persistentInstance);

    BuildsEntity findById(Integer id);

    List findByProperty(String propertyName, Object value);

    List findByBuildNum(Object buildNum);

    List findByCauseAction(Object causeAction);

    List findByAuthor(Object author);

    List findByResult(Object result);

    List findByDuration(Object duration);

    List findByBuildOn(Object buildOn);

    List findByFailCount(Object failCount);

    List findBySkipCount(Object skipCount);

    List findByTotalCount(Object totalCount);

    List findAll();

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    BuildsEntity merge(BuildsEntity detachedInstance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void attachDirty(BuildsEntity instance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void attachClean(BuildsEntity instance);

    List<String> findProjectAllBuildsNumber(ProjectsEntity projectsEntity);

    List<Integer> findBuildsByProjectIdAndBuildNumber(Integer projectId, String buildNum);
}
